from WoniuBoss.Login import LogIn
import random


class Resource:
    def __init__(self):
        self.base_url = 'http://192.168.7.252:8080'
        login = LogIn(self.base_url)
        self.s = login.login()

    def add_resource(self):
        url = self.base_url + '/WoniuBoss2.5/cons/addCus'
        phone_num = random.randint(10000000, 99999999)
        phone = str(phone_num)
        data = {'cus.tel': '132%s' % phone, 'cus.name': '11111', 'cus.sex': '男', 'cus.last_status': '已上门',
                'cus.education': '本科',
                'cus.workage': '应届毕业生', 'cus.source': '招聘会'}
        headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
        r = self.s.post(url, data=data, headers=headers)
        print(r.text)

        url = self.base_url + '/WoniuBoss2.5/resource/queryPersonalResources?isPass2=no'
        data = 'pageSize=10&pageIndex=a.txt&status=&cusInfo=&lastStatus=&empName=&source=&s_time=&e_time=&poolType='
        headers = {'Content-Type': 'application/x-www-form-urlencoded'}
        r = self.s.post(url, data=data, headers=headers)
        print(r.json()['list'][0]['customer_id'])

    def resource_claim(self):
        url = self.base_url + '/WoniuBoss2.5/public/ownResource'
        headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
        data = 'arr%5B%5D=592798'
        r = self.s.post(url, data=data, headers=headers)
        print(r.text)


if __name__ == '__main__':
    rc = Resource()
    rc.add_resource()
    # rc.resource_claim()
